/** \file    registry.h
  * \brief   Implementation of our "xml" tree manipulation engine for Windows Registry.
  * \date    2003
  * \author  Fedor Chelnokov
  * \version $Header: /home/cscom1r4/cvsroot/cs/include/mswin/registry.h,v 1.2 2004/03/26 05:58:02 cscom1r4 Exp $
  */

#ifndef _registry_h_
#define _registry_h_

#include "xml/impl.h"

#define WIN32_LEAN_AND_MEAN
#include <windows.h> //for HKEY only :(

namespace xml {

class key_named_child_enum;
class key_children_enum;

class registry : public implementation {
public:
	///duplicate of hkey is created so the caller should close its handle by itself
	registry(HKEY hkey);
	registry(HKEY hkey, const string & subkey);
	~registry();
	node root();
	const_node root() const;
	void erase(const node & n, const string & subkey);
private:
	// handle management
	virtual handle copy(handle h);
	virtual void release(handle h);
	virtual bool null(handle h);
	// tag access
	virtual string get_tag(handle h);
	// attribute access
	virtual attribute_enumeration * get_attributes(handle h);
	virtual bool get_attribute(handle h, const string & name, string & value);
	virtual void set_attribute(handle h, const string & name, const string & value);
	// children access
	virtual node_enumeration * get_children(handle h);
	virtual node_enumeration * get_children_by_tag(handle h, const string & tag);
	// creation/deletion
	virtual handle create_child(handle h, const string & tag);
	virtual void clear(handle h, bool attr, bool children);
	///not supported
	virtual void erase(handle h);
private:
	class element;
	element * _root;
private:
	friend class key_named_child_enum;
	friend class key_children_enum;
};

} //namespace xml

#endif //_registry_h_
